// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (c) 2023 Yevhen Babiichuk (DustDFG)

#ifndef _VIEW_TUBE_HPP_
#define _VIEW_TUBE_HPP_

#include <cstdint>
#include <vector>

#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Drawable.hpp>

#include <Abracadabra/View/Theme.hpp>

namespace View
{

class Tube : public sf::Drawable
{
	private:
		void drawCurrentDotsTextures() const;
		void drawTubeTextures() const;

		virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;

		uint8_t size;

	public:
		Tube(uint8_t size, sf::FloatRect rect);

		std::vector<sf::RectangleShape> rects;

		Theme* theme;

		sf::RectangleShape& operator[](uint8_t index)
		{
			return this->rects[index];
		}

		void updateDot(sf::RectangleShape& dotRect, std::optional<uint8_t> dot);
		void update(const std::vector<uint8_t>& dots);
};

}

#endif
